package com.tl.bootmeter.controller;

import com.tl.bootmeter.pojo.MeterMode;
import com.tl.bootmeter.service.IMeterModeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

@Controller
@RequestMapping("metermode")
public class MeterModeController {
    @Autowired
    private IMeterModeService meterModeServiceImpl;

    /**
     * 跳转到24条数据的页面
     */
    @RequestMapping("/gotoMode.do")
    private ModelAndView gotoMeterModeTable(String meter_sn){
        System.out.println("页面传入的仪表编号:"+meter_sn);
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("meter_sn",meter_sn);
        modelAndView.setViewName("meter_mode_tables");
        return modelAndView;
    }
    /**
     * 根据仪表编号查询最近日期的24条数据
     * @param meter_sn	仪表编号
     * @return			仪表数据列表
     */
//    @RequestMapping("/findAllMeterModeBySn.do")
//    public ModelAndView findAllMeterModeBySn(String meter_sn){
//        ModelAndView mv = new ModelAndView();
//        List<MeterMode> meterModes = meterModeServiceImpl.findAllMeterModeBySn(meter_sn);
//        mv.addObject("meterModes", meterModes);
////        mv.addObject("meter_sn", meterModes.get(0).getMeter_sn());
//        mv.setViewName("meter_mode_tables");
//        return mv;
//    }
    @RequestMapping("/findAllMeterModeBySn.do")
    @ResponseBody
    public List<MeterMode> findAllMeterModeBySn(String meter_sn){
        ModelAndView mv = new ModelAndView();
        List<MeterMode> meterModes = meterModeServiceImpl.findAllMeterModeBySn(meter_sn);
        System.out.println("查询出来的结果集="+meterModes);
        return meterModes;
    }


}
